<?php
require_once("admin_header.php");
require_once("../include/bm_config.php");
require_once("../include/set_get_key.php");
$sql      = "SELECT max(`user_num`) as upid, min(`user_num`) as btid  FROM `cr_user`";
$page_cnt = 50;
$result   = mysql_query($sql);
echo mysql_error();
$row  = mysql_fetch_object($result);
$base = intval($row->btid);
$cnt  = intval($row->upid) - $base;
$cnt  = intval($cnt / $page_cnt) + (($cnt % $page_cnt) > 0 ? 1 : 0);
if (isset($_GET['page']))
    $page = intval($_GET['page']);
else
    $page = $cnt;
$pstart = $base + $page_cnt * intval($page - 1);
$pend   = $pstart + $page_cnt;
$sql = "select `user_num`, `user_id`,`user_name`,`user_school`,`user_email`,`user_phone`,`user_regtime`, `user_order0`,`user_order1`,`user_active0`,`user_active1`, `user_doc` FROM `cr_user` where user_num>=$pstart and user_num <=$pend order by `user_active1` asc, `user_active0` asc, `user_num` desc";
$result = mysql_query($sql) or die(mysql_error());


?>

<style type="text/css">
<!--
.STYLE1 {color: #FFFFFF}
.STYLE2 {font-size: 12px}
.green  {color: green}
.red    {color: red}
-->
</style>
      <div class="fr wid59">
        <h2 class="h2">用户列表</h2>
        <?php 
        
				for ($i = 1; $i <= $cnt; $i++) 
				{
				    if ($i > 1)
				        echo '&nbsp;';
				    if ($i == $page)
				        echo "<span class=red>$i</span>";
				    else
				        echo "<a href='user_list.php?page=" . $i . "'>" . $i . "</a>";
				}
				?>
        <div class="middle"><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
  <tr>
    <td nowrap height="30" align="center" bgcolor="#316fb5"><h4 class="STYLE3 STYLE1">编号</h4></td>
    <td nowrap align="center" bgcolor="#316fb5"><h4 class="STYLE3 STYLE1">用户名</h4>      </td>
    <td nowrap align="center" bgcolor="#316fb5"><h4 class="STYLE3 STYLE1">姓名</h4>      </td>
    <td nowrap align="center" bgcolor="#316fb5"><h4 class="STYLE3 STYLE1">学校</h4></td>
    <td nowrap align="center" bgcolor="#316fb5"><h4 class="STYLE3 STYLE1"><?php echo $MSG_CONTEST_LEADER_CHOSE;?></h4></td>
    <td nowrap align="center" bgcolor="#316fb5"><h4 class="STYLE3 STYLE1">注册时间</h4></td>
    <td nowrap align="center" bgcolor="#316fb5"><h4 class="STYLE3 STYLE1"><?php echo $sf_name;?></h4></td>
    <td nowrap align="center" bgcolor="#316fb5"><h4 class="STYLE3 STYLE1"><?php echo $rj_name;?></h4></td>
    <td nowrap align="center" bgcolor="#316fb5"><h4 class="STYLE3 STYLE1">证明公文</h4></td>
    <td nowrap align="center" bgcolor="#316fb5"><h4 class="STYLE3 STYLE1">操作</h4></td>
    </tr>
    <?php 
	for (; $row = mysql_fetch_object($result); ) 
	{
	?>
  <tr>
    <td height="30" align="center" bgcolor="#D4DFFF"><span class="STYLE2"><?php echo $row->user_num;?></span></td>
    <td align="center" bgcolor="#D4DFFF"><a href="../userinfo.php?user_id=<?php echo $row->user_id;?>"><span class="STYLE2"><?php echo $row->user_id?></span></a></td>
    <td nowrap align="center" bgcolor="#D4DFFF"><span class="STYLE2"><?php echo $row->user_name?></span></td>
    <td align="center" bgcolor="#D4DFFF"><span class="STYLE2"><?php echo $row->user_school?></span></td>
    <td align="center" bgcolor="#D4DFFF"><span class="STYLE2">
    	<?php 
    	if($row->user_order0 == 'Y' && $row->user_order1 == 'Y') 
        	echo $sf_name."、".$rj_name; 
		else if($row->user_order0 == 'Y') 
        	echo $sf_name;
        else if($row->user_order1 == 'Y')
        	echo $rj_name;
        else
        	echo "竟然都没选"
    	?>
    	</span>
    </td>
    <td align="center" bgcolor="#D4DFFF"><span class="STYLE2"><?php echo $row->user_regtime?></span></td>
    
    <td align="center" bgcolor="#D4DFFF">
	    <?php 
	    echo "<a href=user_df_change.php?user=$row->user_id&to_active=0&getkey=" . $_SESSION['getkey'] . ">" . ($row->user_active0 == "N" ? "<span class=red>改为激活</span>" : "<span class=green>改为冻结</span>") . "</a>";
	    ?>
	    </a></td>
	<td align="center" bgcolor="#D4DFFF">
	    <?php 
	    echo "<a href=user_df_change.php?user=$row->user_id&to_active=1&getkey=" . $_SESSION['getkey'] . ">" . ($row->user_active1 == "N" ? "<span class=red>改为激活</span>" : "<span class=green>改为冻结</span>") . "</a>";
	    ?>
	    </a></td>
    <td align="center" bgcolor="#D4DFFF"><span class=" STYLE2">
    	<?php 
    	if(strlen($row->user_doc))
	    	echo "<a href='".$BM_HOME.$row->user_doc."'>下载公文</a>";
	    else
	    	echo "未上传";
    	?>
    </span></td>
    <td align="center" bgcolor="#D4DFFF">
    <?php
    
	    	echo "<a href='./user_delete.php?usernum=".$row->user_num."' onclick='return confirm(\"删除是不可恢复的，确认要删除吗？\");'>删除</a>";
	  ?>
	</td>
    </tr>
    <?php 
	}
	?>

</table>
        </div>
  </div>
     
      <?php 
      require_once("menu.php");
      require_once("admin_footer.php");
      
      
      ?>
